package com.candoit.webapps.pricing.bean.adapters;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import com.candoit.webapps.pricing.model.TipoLinea;
import com.candoit.webapps.pricing.util.QueryUtil;

public class MyTipoLineaConverter implements Converter {

	public String getAsString(FacesContext context, UIComponent component,
			Object value) {
		if (value != null){
			TipoLinea t = (TipoLinea)value;
			return t.getDescripcion();
		}else{
			return null;
		}
	}

	public Object getAsObject(FacesContext context, UIComponent component,
			String value) {
		return QueryUtil.getInstance().getTipoLineaByDescripcion(value);
	}

}
